from datetime import datetime
from decimal import Decimal
from typing import Optional

from pydantic import BaseModel, ConfigDict, Field
from pydantic.alias_generators import to_camel

from module_admin.annotation.pydantic_annotation import as_query


class StatPositionModel(BaseModel):
    """
    股票交易统计表对应pydantic模型
    """
    model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)

    trade_date: Optional[datetime] = Field(default=None, description='交易日期')
    account_tag: Optional[str] = Field(default=None, description='股票账号标签')
    stock_code: Optional[str] = Field(default=None, description='证券代码')
    stock_name: Optional[str] = Field(default=None, description='证券名称')
    amount: Optional[Decimal] = Field(default=None, description='买入金额')
    quantity: Optional[int] = Field(default=None, description='买入数量')
    create_time: Optional[datetime] = Field(default=None, description='创建时间')


class StatPositionQueryModel(StatPositionModel):
    """
    股票交易统计不分页查询模型
    """
    pass


@as_query
class StatPositionPageQueryModel(StatPositionQueryModel):
    """
    股票交易统计分页查询模型
    """
    is_page: bool = Field(default=True, description='是否分页')
    page_num: int = Field(default=1, description='当前页码')
    page_size: int = Field(default=10, description='每页记录数')


class DeleteStatPositionModel(BaseModel):
    """
    删除股票交易统计模型
    """

    model_config = ConfigDict(alias_generator=to_camel)

    trade_dates: str = Field(description='需要删除的交易日期')
